<template>
  <div class="my-menu">
    <el-menu
      :default-active="defaultMenu"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
      background-color="#000"
      text-color="#fff"
      active-text-color="#fff"
      router
    >
      <div v-for="(item,index) in menuData" :key="index">
        <div v-if="item.onTips">
          <el-badge :value="12" class="item" v-if="item.menuChild.length == 0">
            <el-menu-item :index="item.router">
              <i class="el-icon-menu"></i>
              <span slot="title">{{item.menuTxt}}</span>
            </el-menu-item>
          </el-badge>
          <el-submenu v-else :index="item.router">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span slot="title">{{item.menuTxt}}</span>
            </template>
            <el-menu-item-group>
              <el-menu-item
                v-for="(childItem,childIndex) in item.menuChild"
                :key="childIndex"
                :index="childItem.router"
              >{{childItem.menuTxt}}</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </div>
        <div v-else>
          <!-- <el-badge is-dot class="item" v-if="item.menuChild.length == 0"> -->
          <el-menu-item v-if="item.menuChild.length == 0" :index="item.router">
            <i class="el-icon-menu"></i>
            <span slot="title">{{item.menuTxt}}</span>
          </el-menu-item>
          <!-- </el-badge> -->
          <el-submenu v-else :index="item.router">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span slot="title">{{item.menuTxt}}</span>
            </template>
            <el-menu-item-group>
              <el-menu-item
                v-for="(childItem,childIndex) in item.menuChild"
                :key="childIndex"
                :index="childItem.router"
              >{{childItem.menuTxt}}</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </div>
      </div>
    </el-menu>
  </div>
</template>

<script>
export default {
  name: 'myMenu',
  props: {
    menuData: {
      type: Array
    }
  },
  data () {
    return {
      uuid: sessionStorage.getItem('u')
    }
  },
  computed: {
    defaultMenu () {
      // ////console.log(this.$route)
      return this.$route.path
    }
  },
  created () {},
  mounted () {},
  watch: {},
  methods: {
    handleOpen (key, keyPath) {
      // //console.log(key, keyPath)
    },
    handleClose (key, keyPath) {
      // //console.log(key, keyPath)
    }
  },
  components: {}
}
</script>

<style scoped lang="less">
@import url("./index.less");
</style>
<style>
.el-menu {
  border: 0 !important;
}
.el-menu-item.is-active {
  background-color: #409eff !important;
}
.item {
  width: 100%;
  text-align: left;
}
.el-badge__content.is-fixed.is-dot {
  right: 124px !important;
}
.el-badge__content.is-fixed {
  top: 15px !important;
  right: 50% !important;
}
.el-menu-item,
.el-submenu__title {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
}

</style>
